<template>
	<view class="container">
		<block v-if="NoticeList.length>0">
		<view class="notice_item"  v-for="(item,index) in NoticeList" :key="index" @tap='jump(item.id)'>
			<view class="notice_item_flex">
				<text class="notice_item_text1">{{item.title}}</text>
				<text class="notice_item_text2">{{item.update_time}}</text>
			</view>
			<view>
				<text class="notice_item_text3">{{item.description}}</text>
			</view>
		</view>
		</block>
		<view class="empty-container" v-else>
			<u-empty text="暂无相关内容" :icon="emptyIcon"/>
		</view>
	</view>
</template>

<script>
	var _this;
	export default {
		data() {
			return {
				emptyIcon:'https://farm-city.oss-cn-hangzhou.aliyuncs.com/static/common/empty.png',
				hasMore:true,
				//页数
				pageIndex:1,
				//公告列表
				NoticeList:[]
			}
		},
		onLoad() {
			_this=this
			this.getnoticelist()
		},
		onReachBottom() {
			if(this.hasMore){
				this.pageIndex++;
				this.getnoticelist();
			}
		},
		methods: {
			//公告列表
			async getnoticelist(){
				const params = {
					pageIndex: this.pageIndex,
					pageSize:20,
				}
				const data = await _this.$post('api/GetEssay',params)
				this.NoticeList.push(...data.data.essay)
				this.hasMore=data.data.essay.length>=20
			},
			//路由跳转
			jump(id) {
				this.$u.route({
					url:'/pages/index/html-detail',
					params: {
						title:'公告详情',
						url:encodeURIComponent('/api/EssayDetail?essay_id='+id)
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.container{
	}
	.notice_item {
		margin-bottom: 20rpx;
		background: #fff;
		padding: 20rpx 30rpx 30rpx 30rpx;
		border-radius: 20rpx;
		.notice_item_flex {
			display: flex;
			align-items: center;
			margin-bottom: 20rpx;
			position: relative;
			image {
				width: 80rpx;
				height: 80rpx;
				margin-right: 20rpx;
				border-radius: 6rpx;
			}
			.notice_item_text1 {
				font-size: 30rpx;
				flex: 1;
				font-weight: 500;
			}
			
			.notice_item_text2 {
			}
		}
		.notice_item_text3{
		}
	}
</style>
